﻿@using Newtonsoft.Json
@using StackExchange.Opserver.Data.CloudFlare
@using StackExchange.Opserver.Views.CloudFlare
@model DashboardModel
@{
}
<style>
    .vertical-servers {
        text-align: center;
    }
     .vertical-server {
         border: solid 1px #eee;
         border-radius: 10px;
         display: inline-block;
         vertical-align: top;
         margin: 10px;
     }
    .vertical-server .server-name {
        font-weight: bold;
        font-size: 14px;
        color: #444;
        padding: 5px;
        border-bottom: solid 1px #BBB;
    }
    .server-name .last-updated {
        float: right;
    } 
    .json-output {
        white-space: pre;
        font-family: consolas;
    }
</style>
<div class="vertical-servers">
    @foreach (var rg in Model.Railguns)
    {
        var stats = rg.Stats;
        <div class="vertical-server" style="width: 300px;">
            <div class="server-name">
                @rg.Name
                <span class="last-updated">
                    @rg.Stats.ToPollSpan()
                </span>
            </div>
        @if (stats == null || stats.Data == null)
        {
            <div style="text-align: center; padding: 20px" class="critical">
                Error polling node
            </div>
        }
        else
        {
            dynamic parsedJson = JsonConvert.DeserializeObject(stats.Data);
            var formatted = JsonConvert.SerializeObject(parsedJson, Formatting.Indented);
            <div class="json-output">@formatted</div>
        }
        </div>
    }
</div>